Skip to content

refactor: introduce PerstackError for user-facing error handling#527

Merged
FL4TLiN3 merged 4 commits intomainfrom
refactor/perstack-error-system
Feb 15, 2026
Merged

refactor: introduce PerstackError for user-facing error handling#527
FL4TLiN3 merged 4 commits intomainfrom
refactor/perstack-error-system

Conversation

@FL4TLiN3
Copy link
Contributor

Summary

  • Add PerstackError class to @perstack/core to distinguish known user-facing errors from unexpected bugs
  • PerstackError → message only + exit(1), plain Error → stack trace crash for debugging
  • Centralize error handling at CLI entry points (program.parseAsync().catch(...)) in both perstack and create-expert
  • Remove per-handler try/catch blocks from startHandler, runHandler, logHandler, installHandler
  • Convert 40+ throw sites across 12 files to use PerstackError for validation, config, env var, and API errors
  • Replace ProviderNotInstalledError with PerstackError and remove the old class

Test plan

  • pnpm typecheck — 22/22 packages pass
  • pnpm test — 100 test files, 1090 tests pass
  • pnpm build — 22/22 packages build
  • pnpm format-and-lint — no new warnings
  • Manual: perstack start without perstack.toml shows clean message + exit(1), no stack trace
  • Manual: intentional throw new Error("boom") produces stack trace crash

🤖 Generated with Claude Code

FL4TLiN3 and others added 4 commits February 15, 2026 13:50
Add PerstackError class to distinguish known user-facing errors (message only, exit 1) from unexpected bugs (stack trace crash). Centralize error handling at CLI entry points via parseAsync().catch(), remove per-handler try/catch blocks, and replace ProviderNotInstalledError with PerstackError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Convert missed throw sites found during code review:
- parseExpertKey validation in core/schemas/runtime.ts
- run-manager.ts checkpoint/run lookup errors in tui
- command-args.ts skill config validation in runtime

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Found by second round of full-codebase review:
- setup-experts.ts: delegate resolution error
- providers (anthropic, azure-openai, google, openai): config validation
  for custom skill JSON and missing vectorStoreIds/fileSearchStoreNames
- tui-components: user-initiated cancellation (Ctrl+C)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FL4TLiN3 FL4TLiN3 force-pushed the refactor/perstack-error-system branch from e41896d to b2bf3b1 Compare February 15, 2026 13:50
@FL4TLiN3 FL4TLiN3 merged commit 6d40f55 into main Feb 15, 2026
11 checks passed
@FL4TLiN3 FL4TLiN3 deleted the refactor/perstack-error-system branch February 15, 2026 13:51
@FL4TLiN3 FL4TLiN3 mentioned this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant